<?php 
set_time_limit(0);
ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../connection/connection.php';
$winH = 520;
	if(isset($_REQUEST['winH'])) $winH = $_REQUEST['winH'];
	
?>
<div id="divscroll"  style="overflow:scroll;overflow-x:hidden; width:100%; height:<?=$winH?>px; background-color: #ffffff">
               <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" style="margin-top:0" id="tablebody">
					<tbody>
    				<?php
    				$listSearch = mysql_query("select * from alarm_dat",$connection);
    				$page = 1;
    				$rows_per_page = 100;
    				$number_of_page = 0;
					if (mysql_num_rows( $listSearch )>0) {
						$number_of_page = ceil ( mysql_num_rows( $listSearch ) / $rows_per_page );
					}
	
    				
					$mylist = array();	
					$index=0;
    				while ($row = mysql_fetch_array($listSearch)){
    					$index++;
    					$cartype_ = rtrim($row['cartype']);
    					array_push($mylist, array($row['carnumber'],$row['code1'],$cartype_,$row['code2']));
    					if ($index<=$rows_per_page) {
					 ?>
					 <tr>
					 	<td  width="10%" align="center"><?=$index?></td>
					 	<td  width="30%"><?=$row['carnumber']?></td>
					 	<td  width="20%"><?=$row['code1']?></td>
					 	<td  width="20%"><?=$cartype_?></td>
					 	<td   class="last"><?=$row['code2']?></td>
					 </tr> 
					 <?php  }
    				}
					 
					 $_SESSION['s_alarm'] = $mylist;
					 
					 if ($index<$winH/28) {
					 	foreach(range(0,$winH/28-$index) as $i){
					 		?>
					 		<tr>
					 		<td width="10%">&nbsp;</td>
						 	<td width="30%">&nbsp;</td>
						 	<td width="20%">&nbsp;</td>
						 	<td width="20%">&nbsp;</td>
						 	<td   class="last">&nbsp;</td>
						 	</tr>
					 	<?php }
					}
					?>  
					 </tbody>        
               </table>
       </div>
       <?php if ($number_of_page >1){?>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung" id="tablefooter">
			<tr>
						<td class="rf-dt-ftr-c" style="text-align: center; padding:1px 0px;border:0 !important" >
								<span style="padding:1px; display: inline-block;">
															
									<?php if ( $number_of_page > 1 ) 
									{ 
										$numberperpage = 15;
										$thuong = intval($page/$numberperpage);
										if ($numberperpage>$number_of_page) {
											$pp = $number_of_page;
											$p = 1;
										}
										else if($page<$numberperpage){
											$pp = $numberperpage;
											$p = 1;
										}else{
											$sodu = intval($page%$numberperpage);
											if ($sodu==0) $thuong = $thuong-1;
											$p = ($thuong*$numberperpage)+1;
											$pp = $p+$numberperpage-1;
											if($pp>=$number_of_page){
												$pp = $number_of_page;
											}
										}
										
										if($p>$numberperpage){?>
											<a onclick="OnPagging(<?=1?>,<?=$rows_per_page?>,<?=$number_of_page?>),"><span class='button_next'><?php echo "<<<";?></span> </a>
											<a onclick="OnPagging(<?=($p-1)?>,<?=$rows_per_page?>,<?=$number_of_page?>)"><span class='button_next'><?php echo "<<";?></span> </a>
										<?php  }
										else{
											echo "<span class='button_next'  style='cursor:auto'><<<</span> "; 
											echo "<span class='button_next'  style='cursor:auto'><<</span> ";
										}
										for ( $i = $p; $i <= $pp; $i++ ) {	
												if ($i<=$number_of_page && $i>0)
													if ($i==$page){
														echo "<span class='button_next' style='color: blue;'><b>".$i."</b></span>"; 
													}else{
													?>
														<a onclick="OnPagging(<?=$i?>,<?=$rows_per_page?>,<?=$number_of_page?>)"><span class="button_next">
														<?php echo $i;?>
														</span> </a>
														<?php 
													}
												?>
											
										<?php 
												}
											
											if($pp<$number_of_page){ ?>
												<a onclick="OnPagging(<?=$pp+1?>,<?=$rows_per_page?>,<?=$number_of_page?>)"><span class='button_next'><?php echo ">>";?></span> </a>
												<a onclick="OnPagging(<?=$number_of_page?>,<?=$rows_per_page?>,<?=$number_of_page?>)"><span class='button_next'><?php echo ">>>";?></span> </a>
											<?php }
											else{
												echo "<span class='button_next'  style='cursor:auto'>>></span> ";
												echo "<span class='button_next'  style='cursor:auto'>>>></span> ";
											}
										}
										
										?>
								</span>
	               			 </td>
						</tr> 
					</table>
					
			<?php }
       		
mysql_close($connection);

?>  